package ru.nsu.ccfit.dronov;

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.JAXBException;
import java.util.List;
import java.util.ArrayList;
import java.io.ByteArrayOutputStream;

/**
 * Created by IntelliJ IDEA.
 * User: Asus
 * Date: 16.12.2009
 * Time: 3:17:17
 * To change this template use File | Settings | File Templates.
 */
@XmlRootElement(name = "Base")
public class ProfileBase {
    @XmlElementWrapper(name ="Registered_users")

    private List<Profile> profiles;

    public ProfileBase( ) {
        this.profiles = new ArrayList<Profile>();
    }
    //------------------------------------------------------------------------------------------------------------------
    public boolean checkUser(CheckableUser user)
    {
        if (null == user)
            return false;
        for (int i=0;i<profiles.size();i++)
        {
            if (profiles.get(i).getLogin().equals(user.getLogin()) && profiles.get(i).getPassword().equals(user.getPassword()))
            {
                return true;
            }
        }
        return false;
    }
    //------------------------------------------------------------------------------------------------------------------
    public void addUser(Profile user)
    {

        profiles.add(user);
    }
}
